<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: Z-7
  Date: 2022/3/1
  Time: 12:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<form action="${pageContext.request.contextPath}/brands/list" method="post">
    <input type="hidden" name="pageNum" value="${page.pageNum}">
</form>
<table class="table table-hover">
    <thead>
    <tr>
        <th scope="col">品牌编号</th>
        <th scope="col">品牌名称</th>
        <th scope="col">操作</th>
    </tr>
    </thead>
    <tbody>
        <c:forEach items="${page.list}" var="brand">
            <tr>
                <th>${brand.id}</th>
                <td>${brand.brandName}</td>
                <td>
                    <button type="button" class="btn btn-warning">删除</button>
                    <button type="button" class="btn btn-info">修改</button>
                    <button type="button" class="btn btn-light">详情</button>
                </td>
            </tr>
        </c:forEach>
        <tr>
            <td colspan="100">
                <button type="button" onclick="exportPDF(1)" class="btn btn-outline-dark">预览pdf</button>
                <button type="button" onclick="exportPDF(0)" class="btn btn-outline-dark">导出pdf</button>
            </td>
        </tr>
    <tr>
        <td colspan="100">
            <button type="button" onclick="goPage(1)" class="btn btn-outline-warning">首页</button>
            <button type="button" onclick="goPage(${page.pageNum == 1 ? 1 : page.pageNum - 1})" class="btn btn-outline-info">上一页</button>
            <button type="button" onclick="goPage(${page.pageNum == page.pages ? page.pages : page.pageNum + 1})" class="btn btn-outline-secondary">下一页</button>
            <button type="button" onclick="goPage(${page.pages})" class="btn btn-outline-dark">尾页</button>
        </td>
    </tr>
    </tbody>
</table>
<script type="text/javascript">
    function goPage(pageNum) {
        $('[name="pageNum"]').val(pageNum);
        enterFun("${pageContext.request.contextPath}/brands/list?"+$("form").serialize());
    }
    function exportPDF(mode) {
        window.open('${pageContext.request.contextPath}/brands/exportPDF?mode='+mode);
    }
</script>